package com.leeon.container.map;

import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.TreeSet;

import static net.mindview.util.Print.print;

public class Exmaple24 {

    public static void main(String[] args){
        LinkedHashMap<String,MapStorage> linkedHashMap = new LinkedHashMap<>();
        linkedHashMap.put("eeee",new MapStorage("eee"));
        linkedHashMap.put("gggg",new MapStorage("ggg"));
        linkedHashMap.put("aaaa",new MapStorage("aaaa"));

        print(linkedHashMap);
        Map<String,MapStorage> m2=new LinkedHashMap<String,MapStorage>();
        TreeSet<String> treeSet = new TreeSet<>(linkedHashMap.keySet());
        Iterator<String> it = treeSet.iterator();
        while (it.hasNext()){
            String key = it.next();
            m2.put(key,linkedHashMap.get(key));
        }
        linkedHashMap.clear();
        linkedHashMap.putAll(m2);
        print(linkedHashMap);
    }

}
